package com.t2t.top.beanfactory;

import org.springframework.beans.factory.FactoryBean;

public class PeopleFactoryBean implements FactoryBean<People> {

    private String phoneInfo;

    public String getPhoneInfo() {
        return phoneInfo;
    }

    public void setPhoneInfo(String phoneInfo) {
        this.phoneInfo = phoneInfo;
    }

    @Override
    public People getObject() throws Exception {
        People people = new People();
        Phone phone = new Phone();
        String info[] = phoneInfo.split(",");
        phone.setSize(info[0]);
        phone.setName(info[1]);
        phone.setLogo(info[2]);
        people.setName(info[3]);
        people.setPhone(phone);
        return people;
    }

    @Override
    public Class<?> getObjectType() {
        return Phone.class;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }

}  